public class QueueWithStacks<T>{
   Node first, last;
   Stack<T> newest = new Stack<T>();
   Stack<T> oldest = new Stack<T>();
   
    public QueueWithStacks(){
      newest = new Stack<T>();
      oldest = new Stack<T>();
    }
   
   public void enqueue(T value){
      newest.push(value);
   }
  
   public T dequeue(){
      if(oldest.top == null) 
        callNewest();
      else if(oldest.top != null) {
         return oldest.pop();
      }
      return null;  //Returning null here only when the newest stack has no value;
   }
   
    public void callNewest(){
     while(newest.top != null) {
       oldest.push(newest.pop());
     }
     return;
    }
}